package com.moorror.codegenvel.utils;

import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiManager;

/**
 * @Author jiyanghuang
 * @Date 2022/2/26 2:09 PM
 */
public class GoToSourceUtils {

    public static final String CONSTRUCTORS_METHOD_NAME = "<init>";

    public static void openLineInEditor(Project project, String className, int lineNum) {

    }

    protected static void openInEditor(Project project, VirtualFile virtualFile, int offset) {
        if (virtualFile == null)
            return;

        FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project,
                virtualFile, offset), true);
    }

    protected static void openLineInEditor(Project project, VirtualFile virtualFile, int line) {
        if (virtualFile == null)
            return;

        FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project,
                virtualFile, line, 0), true);
    }

    public static PsiManager psiManager(Project project){
        return PsiManager.getInstance(project);
    }
}
